const Router = require("koa-router");
const pool = require('../database.js');
const {anthVertify,getList,postData,putData,deleteData,getListAll} =require('../common/middleware.js')
const router = new Router({
  prefix: "/professionalskills",
});
router.get("/", anthVertify,async(ctx, next) => {
   try {
   await getList(ctx,{table:'professionalskills',otherState:`WHERE userId=${ctx.user.id}`})
   } catch (error) {
      console.log(error);
   }
});
router.get("/getAll", async(ctx, next) => {
   let result= await getListAll(ctx,{table:'professionalskills',queryData:'id professionalskills'})
   ctx.body = result
});
router.get("/getAlled",anthVertify, async(ctx, next) => {
   let result= await getListAll(ctx,{table:'professionalskills',queryData:'id,professionalskills',otherState:`WHERE userId=${ctx.user.id}`})
   ctx.body = result
});
router.post("/", anthVertify,async(ctx, next) => {
   await postData({table:'professionalskills',data:{...ctx.request.body,userId:ctx.user.id},ctx:ctx})
});
router.put("/", async(ctx, next) => {
   await putData('professionalskills',ctx.request.body,ctx)
  });
  router.delete("/:id", async(ctx, next) => {
    let id=ctx.params.id
   await deleteData('professionalskills',id,ctx)
  });
//   exports.router=router
module.exports = router;
